package com.example.ioc.value.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
@PropertySource("classpath:xht.properties")
public class ValuesService {

    @Value("${springName}")
    private String name;

    @Value("#{15*2}")
    private Integer age;

    @Value("#{{'语文':99,'数学':100}}")
    private Map<String, Integer> score;

    @Value("#{'唱歌,打球'}")
    private List<String> hobbies;

    private String catalogName;

    public ValuesService(@Value("${catalog.name:默认值}") String catalogName) {
        this.catalogName = catalogName;
    }

    @Override
    public String toString() {
        return "ValuesService{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                ", hobbies=" + hobbies +
                ", catalogName='" + catalogName + '\'' +
                '}';
    }
}
